﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Xww.Data.Binding {
    /// <summary>
    /// Provide data binding functions to a type of Enum
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class EnumBinder<T> {
        private List<EnumWrapper<T>> pairs;
        /// <summary>Default creator will get all members of type T</summary>
        public EnumBinder() {
            pairs = new List<EnumWrapper<T>>();
            foreach (var item in Enum.GetNames(typeof(T))) {
                pairs.Add(new EnumWrapper<T> { Name = item, Enum = (T)Enum.Parse(typeof(T), item) });
            }
        }
        /// <summary>Get the list of EnumWrapper</summary>
        public List<EnumWrapper<T>> Pairs {
            get { return pairs; }
        }
    }
    ///<summary>Represent one status of Enum type T</summary>
    public class EnumWrapper<T> {
        public string Name { get; set; }
        public T Enum { get; set; }
    }
}
